package org.example.work;

import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.junit.jupiter.api.Test;

public class JasyptTest {

    @Test
    public void JasyptTestDemo(){
        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        //手动设置加密程序的密码
        config.setPassword("abcdefg123456");

        config.setPoolSize(1);

        encryptor.setConfig(config);

        //运行，查看加密后的数据是什么，然后在ENC()中添加
        String url = encryptor.encrypt("jdbc:mariadb://sqlpub.com:3306/dishizu?useSSL=false");
        System.out.println("url="+url);
        String name = encryptor.encrypt("lijia2005");
        System.out.println("name="+name);
        String password = encryptor.encrypt("hDvyAqx6OLdOlGDE");
        System.out.println("pass="+password);

        String host = encryptor.encrypt("localhost");
        System.out.println(host);
    }

}
